Package vg.modules.search.components

Source Code of vg.modules.search.components.SecondPanel

package vg.modules.search.components;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.Set;

import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;

import vg.core.graph.GraphNode;
import vg.core.plugin.PluginParameter;
import vg.modules.search.SearchPanelModel;
import vg.modules.search.components.additionalAttributesPanel.AdditionalAttributePanel;
import vg.modules.search.components.searchTree.SearchTree;

public class SecondPanel {
  private final JPanel view;
  private final PluginParameter parameter;
  private final SearchTree searchTree;
  private final OptionPanel optionPanel;
  private final ActionPanel actionPanel;
  private final JSplitPane treeAndAddSplitPane;
  private final AdditionalAttributePanel aaPanel;
  private final SearchPanelModel model;
  /**
   * Constructor.
   * @param parameter - connection with model and user interface.
   * @param searchPanel - feedback with search panel.
   */
  public SecondPanel(final PluginParameter parameter, final SearchPanelModel model) {
    this.parameter = parameter;
    this.model = model;
    this.view = new JPanel(new GridBagLayout());
    //---------------------------------------
    this.aaPanel = new AdditionalAttributePanel();
    this.searchTree = new SearchTree(this.parameter, this.model);
    this.optionPanel = new OptionPanel(this.model);
    this.actionPanel = new ActionPanel(this.model);
    //create split pane between conditional panel and additional panel
    this.treeAndAddSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, this.searchTree.getView(), this.aaPanel.getView());
    this.treeAndAddSplitPane.setResizeWeight(0.5);
    this.treeAndAddSplitPane.setDividerSize(4);
    //build search panel
    GridBagConstraints gbc = new GridBagConstraints(0,01,11,1,  GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5)0,0);
    this.view.add(this.treeAndAddSplitPane, gbc);

    gbc = new GridBagConstraints(0,11,10,0,  GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5)0,0);
    this.view.add(this.optionPanel.getView(), gbc);
   
    gbc = new GridBagConstraints(0,21,10,0,  GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5)0,0);
    this.view.add(this.actionPanel.getView(), gbc);       
  }
  /**
   * This method builds tree and additional attribute panel.
   */
  public void buildTree(final GraphNode rootNode, final Set<Integer> vertexIdList, final Set<String> vertexAttributes) {
    this.searchTree.replaceNode(rootNode, vertexIdList);
    this.aaPanel.setVertexAttributes(vertexAttributes);
  }
  public synchronized Set<String> getVertexAdditionalAttributes() {
    return(this.aaPanel.getVertexAdditionalAttributes());
  }
  public synchronized void setOptionMode(final int option) {
    this.searchTree.setOptionMode(option);
  }
  public JPanel getView() {
    return(this.view);
  }
  /**
   * This method updates user interface.
   */
  public synchronized void updateUITheme() {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        SwingUtilities.updateComponentTreeUI(SecondPanel.this.view);
      }
    });
  }
}
TOP

Related Classes of vg.modules.search.components.SecondPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.